<template>
  <div class="search-history">
    <van-cell title="搜索历史">
      <div v-if="show">
       <span @click='$emit("clear-search-history")'>全部删除</span>
       &nbsp;
       <!-- 点击完成退出删除状态 -->
      <span  @click="show=!show">完成</span>

      </div>

      <van-icon v-else name="delete" @click="show=!show" />
    </van-cell>
    <van-cell @click="oncl(value,index)" :title="value"  v-for="(value,index) in arr" :key="index">
      <van-icon v-if="show" name="close" />
    </van-cell>

  </div>
</template>

<script>
export default {
  name: 'SearchHistory',
  components: {},
  props: {
    arr: {
      type: Array,
      required: true
    }
  },
  data () {
    return {
      // 控制删除
      show: false
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    oncl (value, index) {
      if (this.show) {
        // 删除状态
        this.arr.splice(index, 1)
      } else {
        // 不是删除状态

        this.$emit('seacht', value)
      }
    }

  }
}
</script>

<style scoped lang="less"></style>
